UICommonHeroUp = {};
HelperFunc.SetUIEnv(UICommonHeroUp)
local this = UICommonHeroUp;

function UICommonHeroUp.ShowInfo(obj, str, isFetter,isAll,befornum,Afternum)
    obj.visible = true;
    local list = HelperFunc.GetSplit(str)
    local num = math.floor(#list / 2);
    local type = "Attr_";
    local typeController = obj:GetController("type");
    local powerCtrl = obj:GetController("powerType")
    local stateCtrl = obj:GetController("powerState")
    local beforePower = obj:GetChild("power")
    local power = obj:GetChild("num")
    local beforePower_d = obj:GetChild("powerDown")
    local power_d = obj:GetChild("num")
    local upCtrl = obj:GetTransition("powerUp")
    local downCtrl = obj:GetTransition("powerDown")
    if typeController then
        if isFetter then
            typeController.selectedIndex = 1;
        else
            typeController.selectedIndex = 0;
        end
    end
    local num_before,num_after
    if befornum then
        num_before,num_after = befornum,Afternum
    else
        num_before,num_after = logicMgr.HeroManager.SetAllPower()
    end
    if isAll  then
        stateCtrl.selectedIndex = 1
    else
        stateCtrl.selectedIndex = 0
        for i = 1, num do
            local tips = obj:GetChild("tipsImprove"..i);
            local attrName = tips:GetChild("title")
            local numBefore = tips:GetChild("numBefore")
            local numAfter = tips:GetChild("numAfter")
            attrName.text = getLanguage(type..i)
            numAfter.text = list[i * 2 - 1];
            numBefore.text = list[i * 2];
        end
    end
    
    utimer.delayCall(function()
        if num_after>=num_before then
            upCtrl:Play()
            powerCtrl.selectedIndex = 0
        else
            downCtrl:Play()
            powerCtrl.selectedIndex = 1
        end
        beforePower.text = Mathf.Round(math.abs(num_after -num_before))
        beforePower_d.text = Mathf.Round(math.abs(num_after -num_before))
        local trans = obj:GetTransition("appear")
        if isFetter then
            trans = obj:GetTransition("appear_fetter")
        end
        trans:Play(function()
            -- 新生成的永远在旧的上面
            obj.sortingOrder = 999;
            --obj.visible = false;
        end);
    end,1)

end

return UICommonHeroUp;